package com.jifujun.junbatis.base.model;

import com.jifujun.junbatis.base.service.PageResult;
import lombok.Data;
import lombok.ToString;

/**
 * Create with IntelliJ IDEA
 * Project Name: junbatis
 * Package Name: club.emergency.junbatis.base.club.emergency.club.emergency.staff.model
 * Date: 2018/4/20 11:06
 * User: 快乐的小菌菌
 * Description: 返回封装（web）
 */
@Data
@ToString
public class Result {
    private Integer code;
    private String message;
    private Object data;

    private Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result ok() {
        return new Result(200, "success", null);
    }

    public static Result ok(Object obj) {
        return new Result(200, "success", obj);
    }

    public static Result ok(PageResult pageResult) {
        return new Result(200, "success", pageResult);
    }

    public static Result err(Object obj) {
        return new Result(201, "error", obj);
    }

    public static Result err(PageResult pageResult) {
        return new Result(201, "error", pageResult);
    }
}
